import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        useMaterial3: false,
        primarySwatch: Colors.yellow,
      ),
      home: Scaffold(
        appBar: AppBar(title: const Text("Flutter App")),
        body: const MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {

    return Stack(
      children: [
        Container(
          width: 400,
          height: 400,
          color: Colors.black54,
        ),
        Positioned(
          /**
           * left,top,bottom,right都是相对于外部容器进行定位
           * 如果没有外部容器，则相对于整个屏
           *
           * child元素必须有具体的高度和宽度，无法使用double.infinity
           * 可以在Positioned内指定，也可以在子元素本身内指定
           */
            left: 10,
            top: 20,
            child: Container(
              color: Colors.yellow,
              width: 200,
              height: 200,
            )
        ),
      ],
    );
  }
}
